package com.chatbi.common;

/**
 * @Author kunge2013
 * @Description 返回结果
 * @Date 2025/1/23 16:08
 * @Version 1.0
 */

public class R {
    public String code;
    public static String CODE_SUCCESS = "1000";
    public String msg;
    public Object data;

    public static R success() {
        return new R(CODE_SUCCESS, "成功");
    }

    public static <T> R success(T data) {
        return new R(CODE_SUCCESS, "成功", data);
    }

    public static <T> R fail(String code) {
        return new R(code, "失败");
    }

    public static <T> R fail(String code, String msg) {
        return new R(code, msg);
    }

    public R(Object data) {
        this.data = data;
    }

    public R(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
